﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;


namespace SC.eWedding.BusinessLogic.Mail
{
    public static class EMail
    {
        public static void MandarMail(string direccionDestino, string asunto, string cuerpo) 
        {
            System.Net.Mail.MailMessage correo = new System.Net.Mail.MailMessage();

            correo.From = new System.Net.Mail.MailAddress("andreabog@gmail.com");
            correo.To.Add(direccionDestino);
            correo.Subject = asunto;
            correo.Body = cuerpo;
            correo.IsBodyHtml = false;
            correo.Priority = System.Net.Mail.MailPriority.Normal;

            //System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
            //smtp.Host = "smtp.gmail.com";

            SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
            smtp.EnableSsl = true;
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.Credentials = new System.Net.NetworkCredential("andreabog@gmail.com", "*******");

            //Solo si necesita usuario y clave
            //smtp.Credentials = new System.Net.NetworkCredential("usuario", "password");
            try
            {
                smtp.Send(correo);
            }
            catch (Exception ex)
            {
                //Controlar el error
            }


        }
    }
}
